package com.xy.ds;

import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.annotation.MapperScans;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan("com.xy.ds.mapper")


/**
 * 使用mybaties plus 定义的多数据源 比较简单，
 * 1，引入pom：
 *  <dependency>
 *             <groupId>com.baomidou</groupId>
 *             <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
 *             <version>${dynamic-datasource.version}</version>
 *         </dependency>
 * 2,更新配置文件
 *
 * dynamic:
 *       primary: write
 *       # 未匹配到数据源时，true抛异常，false使用默认数据源
 *       strict: true
 *       datasource:
 *         write:
 *           username: root
 *           password: root
 *           url: jdbc:mysql://127.0.0.1:3306/ds_test?characterEncoding=utf-8&useSSL=false&&serverTimezone=UTC
 *           driver-class-name: com.mysql.cj.jdbc.Driver
 *         read:
 *           username: root
 *           password: root
 *           url: jdbc:mysql://127.0.0.1:3306/ds_read?characterEncoding=utf-8&useSSL=false&&serverTimezone=UTC
 *           driver-class-name: com.mysql.cj.jdbc.Driver
 *
 * 可以参考本配置文件
 *
 * 3，加上DS注解("上面定义的名字write or read")
 */


public class DsApplication {
    public static void main(String[] args) {
        SpringApplication.run(DsApplication.class, args);
    }
}
